$(document).ajaxSend(function(event,xhr,options){
    //从login页面获取toekn
    let token = localStorage.getItem("user_token");
    //设置
    xhr.setRequestHeader("user_header_token",token);
});

$(document).ajaxError(function(event,xhr,options,exc){
    if(xhr.status == 401){
        alert("用户未登录，请先登录");
        location.href = "login.html";
    }
    else if(xhr.status == 404){
        location.href = "../html/404.html";
    }
});